package com.jyq.jsp.servlet;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

/**
 * @author Jiang Yongqiang
 */
public class IndexServlet extends HttpServlet {


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        Enumeration<String> initParameterNames = getInitParameterNames();
        StringBuilder stringBuilder = new StringBuilder();
        while (initParameterNames.hasMoreElements()){
           stringBuilder.append(getInitParameter(initParameterNames.nextElement()));
        }
        request.setAttribute("params",stringBuilder.toString());
        ServletContext servletContext = getServletContext();
        RequestDispatcher requestDispatcher = servletContext.getRequestDispatcher("/jsp/index.jsp");
        requestDispatcher.forward(request,response);
    }
}
